package com.investmenttechnologyservices.util;

import java.util.Random;
import java.util.logging.Logger;


public class RandomStringId {
	
	private static final Logger log = Logger.getLogger(RandomStringId.class.getName());

    private static final String dCase = "abcdefghijklmnopqrstuvwxyz";
    private static final String uCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    private static final String sChar = "!@#$%^&*";
    private static final String intChar = "0123456789";
    private static Random r = new Random();

    static public String setId(int maxLen) {
    	StringBuilder sb = new StringBuilder();
    	int spot;
    	for (int i=0; i<maxLen; i++) {
            int rPick = r.nextInt(4);
            switch (rPick) {
            case 0:
                spot = r.nextInt(25);
                sb.append(dCase.charAt(spot));
                break;
            case 1:
                spot = r.nextInt (25);
                sb.append(uCase.charAt(spot));
                break;
            case 2:
                spot = r.nextInt (7);
                sb.append(sChar.charAt(spot));
                break;
            case 3:
                spot = r.nextInt (9);
                sb.append(intChar.charAt (spot));
                break;
            }
        }
    	String ret = sb.toString();
        log.info("Generated Id: " + ret);
        return ret;
    }
}
